<?php

namespace app\backend\controller;

use app\backend\service\CashService;
use app\backend\service\FeedbackService;
use app\backend\service\MemberService;
use app\backend\service\MoneyRecordService;

class Popup extends Backend
{
    /**
     * 用户详情
     * @param MemberService $service
     * @return string
     */
    public function userinfo(MemberService $service)
    {
        return $this->fetch('', ['info' => $service->detail($this->request->param('id'))]);
    }

    /**
     * 用户反馈
     * @param FeedbackService $service
     * @return string|\think\response\Json
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     */
    public function feedback(FeedbackService $service)
    {
        if ($this->request->isAjax()) {
            return $this->success($service->lists($this->request->param()));
        }
        return $this->fetch('', $service->feedbackLabel());
    }

    /**
     * 金币明细
     * @param MoneyRecordService $service
     * @return string|\think\response\Json
     * @throws \think\db\exception\DbException
     */
    public function coin(MoneyRecordService $service)
    {
        if ($this->request->isAjax()) {
            return $this->success($service->lists($this->request->param()));
        }
        return $this->fetch('', $service->coinLabel());
    }

    /**
     * 提现记录
     */
    public function cash(CashService $service)
    {
        if ($this->request->isAjax()) {
            return $this->success($service->lists($this->request->param()));
        }
        return $this->fetch('', $service->labelData());
    }

    /**
     * 全部下线
     */
    public function fans(MemberService $service)
    {
        if ($this->request->isAjax()) {
            return $this->success($service->fansList($this->request->param()));
        }
        return $this->fetch('', $service->dataLabel());
    }

    /**
     * 邀请奖励
     */
    public function reward(MemberService $service)
    {
        return $this->fetch('', $service->reward($this->request->param(['memberId' => $this->request->get('id')])));
    }
}